﻿using Engine;
using System.Collections.Generic;
using System.Globalization;
using TemplatesDatabase;
using Game;

namespace Xmod
{
	public class XmodSubsystemPlayers : SubsystemPlayers, IUpdateable
	{
		public override void Load(ValuesDictionary valuesDictionary)
		{
			m_subsystemTime = base.Project.FindSubsystem<SubsystemTime>(throwOnError: true);
			m_nextPlayerIndex = valuesDictionary.GetValue<int>("NextPlayerIndex");
			GlobalSpawnPosition = valuesDictionary.GetValue<Vector3>("GlobalSpawnPosition");
			foreach (KeyValuePair<string, object> item in valuesDictionary.GetValue<ValuesDictionary>("Players"))
			{
				XmodPlayerData playerData = new XmodPlayerData(base.Project);
				playerData.Load((ValuesDictionary)item.Value);
				playerData.PlayerIndex = int.Parse(item.Key, CultureInfo.InvariantCulture);
				m_playersData.Add(playerData);
			}
		}

	}
}
